//
//  FSCObjectiveItemTableController.swift
//  FamiliesSchoolConnection
//
//  Created by 花花蔡 on 2016/12/31.
//  Copyright © 2016年 com.HuaHuaCai. All rights reserved.
//

import UIKit

class FSCObjectiveItemTableController: UITableViewController {

    fileprivate var objectiveListVM = FSCObjectiveListModel()
    var dataArr = [FSCObjectiveModel]()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        tableView.register(UINib(nibName: "FSCObjiectiveCell", bundle: nil), forCellReuseIdentifier: "objiectiveCell")
        tableView.estimatedRowHeight = 150
        tableView.rowHeight = UITableViewAutomaticDimension
        loadData()
        
        
    }

    func loadData() -> Void {
        objectiveListVM.downLoadData { (isok) in
            if isok {
                self.tableView.reloadData()
            }
        }
    }

}


// MARK: - Table view data source

extension FSCObjectiveItemTableController {
    
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return objectiveListVM.objectiveModelArr.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "objiectiveCell", for: indexPath) as! FSCObjiectiveCell
        cell.selectionStyle = .none
        cell.model = objectiveListVM.objectiveModelArr[indexPath.row]
        
//        cell.callBack = { (btnTag) in
//            cell.model?.btnTag = btnTag
//            let btnArr = [cell.A,cell.B,cell.C,cell.D]
//            for btn in btnArr {
//                if btn?.tag == cell.model?.btnTag {
//                    btn?.isSelected = true
//                    btn?.setImage(UIImage(named:"选择"), for: .selected)
//                }else {
//                    btn?.isSelected = false
//                }
//                self.tableView.reloadData()
//            }
//            
//        }

        return cell
    }
    
//    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//        
//        let cell = tableView.cellForRow(at: indexPath) as! FSCObjiectiveCell
//        
////        let model = objectiveListVM.objectiveModelArr[indexPath.row]
//        
//        
//    }
}
